bool isUnivalTree(struct TreeNode* root) {
    if (root != NULL)
    {
        if (root->left != NULL && root->left->val != root->val)
        {
            return false;
        }
        else
        {
            if (root->right != NULL && root->right->val != root->val)
            {
                return false;
            }
            else
            {
                if (root->left == NULL && root->right != NULL)
                {
                    return isUnivalTree(root->right);
                }
                if (root->right == NULL && root->left != NULL)
                {
                    return isUnivalTree(root->left);
                }
                if (root->left != NULL && root->right != NULL)
                {
                    return isUnivalTree(root->left) && isUnivalTree(root->right);
                }
            }
        }
        return true;
    }
    else
    {
        return false;
    }
}